<!DOCTYPE html>
<html lang="zh-Hans">
<head>
    @import "mate.html"
    <title>农业后台系统1</title>
    <link rel="stylesheet" href="../assets/layui/css/layui.css">
    <link rel="stylesheet" href="../css/style.min.css">
</head>
<body class="body">

@import "header.html"

<div class="main">

    @import "aside.html"

    <div id="main-body" class="main-body">
        <div class="content processing">
            <div class="min-content">
                <div class="com-title"><span>权限项目</span></div>
                <div class="com-form-group">
                    <form class="layui-form cf" action="">
                        <div class="com-form-input">
                            <div class="layui-form-item">
                                <label class="layui-form-label">项目名称</label>
                                <div class="layui-input-block">
                                    <input id="comp-id" name="title" placeholder="请输入公司编号" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">项目标示</label>
                                <div class="layui-input-block">
                                    <input name="title" placeholder="请输入标题" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">状态</label>
                                <div class="layui-input-block">
                                    <select name="city" title="">
                                        <option value="">请选择</option>
                                        <option value="0">上架</option>
                                        <option value="1">下架</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="com-form-btn">
                            <button class="y-btn y-btn-search" lay-submit lay-filter="form-search">
                                <span>查询</span></button>
                        </div>
                    </form>
                </div>
                <div class="com-btn-group">
                    <button id="btn-add" class="y-btn y-btn-add" type="button"><span>添加</span></button>
                    <button id="btn-modify" class="y-btn y-btn-modify" type="button"><span>修改</span></button>
                    <button id="btn-putaway" class="y-btn y-btn-putaway" type="button"><span>上架</span></button>
                    <button id="btn-soldout" class="y-btn y-btn-soldout" type="button"><span>下架</span></button>
                </div>
                <div class="com-table-group">
                    <table class="com-table">
                        <thead class="thead">
                        <tr>
                            <td><span><input type="checkbox" id="checkall"></span></td>
                            <td><span>序号</span></td>
                            <td><span>唯一标示</span></td>
                            <td><span>项目描述</span></td>
                            <td><span>图片UI</span></td>
                            <td><span>项目路径</span></td>
                            <td><span>状态</span></td>
                            <td><span>详情</span></td>
                        </tr>
                        </thead>
                        <tbody class="tbody"></tbody>
                    </table>
                </div>
                <div class="com-paging">
                    <div id="page-box"></div>
                </div>
            </div>
        </div>
    </div>
</div>
@import "footer.html"
<script src="../assets/jquery.autocompleter.min.js"></script>
<script>
  $(function () {
    $.ajax({
      url: '../assets/json/table-tbody.json',
      type: 'get',
      dataType: 'json',
      success: function (data) {
        var list = data.list, html = '';
        for (var i = 0; i < list.length; i++) {
          html += '<tr><td><span><input type="checkbox" data-id=' + list[0].cid + '></span></td>' +
            '<td><span class="text-center">' + list[0].cid + '</span></td>' +
            '<td><span class="limit-words-more" title=' + list[i].cname + '>' + list[i].cname + '</span></td>' +
            '<td><span class="text-center">' + list[0].gid + '</span></td>' +
            '<td><span class="tbody-img"><img src="' + list[0].pimg + '" alt=""></span></td>' +
            '<td><span class="limit-words-less" title=' + list[i].gname + '>' + list[i].gname + '</span></td>' +
            '<td><span class="text-center">' + list[0].bid + '</span></td>' +
            '<td><span class="text-center"><button class="y-btn y-btn-detail"><span>详情</span></button></span></td></tr>';
        }
        $('tbody.tbody').html('').append(html);
      },
      complete: function () {
        photos('.tbody-img');
      }
    });
    var form = layui.form,layer=layui.layer;
    var colors = [
      {"label": "宁波工程学院"},
      {"label": "宁波工地学院"},
      {"label": "宁波大红印学院血活动活动发是否地方的"},
      {"label": "宁波碗里学院"}
    ];
    $('#comp-id').autocompleter({
      source: colors,
      empty: false,
      limit: 10,
      callback: function (value, index, selected) {
//        console.log(value,index,selected);
      }
    });

    //监听提交
    form.on('submit(form-search)', function (data) {
      console.log(data.field);
      return false;
    });

    var oInput;
//      添加按钮
    $('#btn-add').on('click', function (e) {
      e.stopPropagation();
      var body;
      dialogShow('添加基本信息', 'pprojectsadd.html', [1000, 500], {
        success: function (obj, index) {
          body = layer.getChildFrame('body', index);
        },
        btn: ['提交', '取消'],
        yes: function () {
          body.find('#form-submit').click();
        }
      });
    });
    //      修改按钮
    $('#btn-modify').on('click', function (e) {
      e.stopPropagation();
      oInput = $('table.com-table').find('input:checked');
      if (oInput.length === 0) {
        errorMsg('请选择要审核的数据！');
      } else if (oInput.length > 1) {
        errorMsg('请不要选择多条数据！');
      } else {
        var body;
        dialogShow('详细信息', 'pprojectsadd.html', [1000, 500], {
          success: function (obj, index) {
            body = layer.getChildFrame('body', index);
          },
          btn: ['提交', '取消'],
          yes: function () {
            body.find('#form-submit').click();
          }
        });
      }
    });

    //    上架按钮
    $('#btn-putaway').on('click',function (e) {
      e.stopPropagation();
      oInput = $('table.com-table').find('input:checked');
      if(oInput.length===0){
        msg('请至少选择一条需要上架的模板！');
      }else {
        confirm('选中的数据是否上架？',{
          yes:function (index,obj) {
            //业务逻辑

            layer.close(index);
          }
        });
      }
    });

//    下架按钮
    $('#btn-soldout').on('click',function (e) {
      e.stopPropagation();
      oInput = $('table.com-table').find('input:checked');
      if(oInput.length===0){
        msg('请至少选择一条需要下架的模板！');
      }else {
        confirm('选中的数据是否下架？',{
          yes:function (index,obj) {
            //业务逻辑


            layer.close(index);
          }
        });
      }
    });

//      表格内详情按钮
    var tbody=$('tbody.tbody');
    tbody.on('click','button.y-btn-detail',function (e) {
      e.stopPropagation();
      var body;
      dialogShow('详情', 'syprocessingDetail.html', [1000, 650], {
        success: function (obj, index) {
          body = layer.getChildFrame('body', index);
        }
      });
    });

//      分页按钮
    var page = layui.laypage;
    page.render({
      elem: 'page-box',
      count: 100,
      groups: 3,
      theme: '#00a65b',
      layout: ['count','prev','page', 'next', 'skip'],
      jump: function (obj, first) {
        var curPage = obj.curr;
        if (!first) {}
      }
    });
  });
</script>
</body>
</html>